package com.qijian.maindata.domain.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.qijian.common.utils.ObjectUtils;
import lombok.Data;
import lombok.ToString;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;

@Data
@ToString
public class ProjectStatusVo {
    private String name;

    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date planTime;

    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date completeTime;

    private BigDecimal totalProcess;
    private BigDecimal completeProcess;
    private BigDecimal process;
    private BigDecimal benefit;

    public BigDecimal getProcess() {
        if (ObjectUtils.isNull(totalProcess) || ObjectUtils.isNull(completeProcess) ||
                BigDecimal.ZERO.compareTo(completeProcess) == 0 || BigDecimal.ZERO.compareTo(totalProcess) == 0)
            return BigDecimal.ZERO;
        return completeProcess.divide(totalProcess, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP);
    }

    public BigDecimal getBenefit() {
        if (ObjectUtils.isNull(benefit)) {
            return benefit;
        }
        return benefit.multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP);
    }
}
